package com.xb.loan.util.binaryConvert.parse.bool;


import com.xb.loan.util.binaryConvert.config.ParseConfig;
import com.xb.loan.util.binaryConvert.parse.ParseAble;
import com.xb.loan.util.binaryConvert.parse.ParsePointer;

public class BoolParser implements ParseAble<Boolean> {

	@Override
	public Boolean convert(byte[] b, ParsePointer pointer, Class<?> clazz, ParseConfig config) {

		byte b1 = b[pointer.getPointer()];
		// 指针后移一个单位
		pointer.move(1);
		
		return b1 == 0 ? false : true;
	}

	@Override
	public byte[] format(Boolean obj,ParseConfig config) {

		return new byte[] { (byte) (obj ? 1 : 0) };
	}

}
